package com.briup.service.Impl;

import com.briup.bean.Collect;
import com.briup.bean.Shop;
import com.briup.bean.User;
import com.briup.dao.ICollectDao;
import com.briup.service.ICollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ICollectServiceImpl implements ICollectService {
    @Autowired
    private ICollectDao collectDao;

    @Override
    public List<Shop> findUserAllCollect(Long id) {

        return collectDao.findByUserId(id);
    }

    @Override
    public void deleteCollect(Long userId, Long shopId) {
        collectDao.deleteByShopIdAndUserId(shopId,userId);
    }


    @Override
    public void addCollect(User user, Long shopId) {
        collectDao.addShopToCollect(user.getId(),shopId);
    }

    @Override
    public boolean findCollect(Long id, Long shopId) {
        return collectDao.findByUserIdAndShopId(id,shopId) != null;
    }

    @Override
    public Collect findOne(Long collectId) {
        return null;
    }
}
